# -*- mode: python; -*-

vpath = '#/third_party/log4cplus-1.1.1'

env = DefaultEnvironment()

config_opts = '--prefix=' + str(Dir('#/build'))

cmd = ('(cd ' + Dir('.').abspath + '; ' + str(Dir(vpath)) +
       '/configure' + ' ' + config_opts + '; make clean; make; make install)')

version = '.7.0.0'
libs = [ str(File('#/build/lib/liblog4cplus' + env['LIBSUFFIX'])) ]
shlibs = [ str(File('#/build/lib/liblog4cplus-1.1' + env['SHLIBSUFFIX'] +
                    version)) ]

headers = [
    '#/build/include/log4cplus/appender.h',
    '#/build/include/log4cplus/config/defines.hxx',
    '#/build/include/log4cplus/config.hxx',
    '#/build/include/log4cplus/config/macosx.h',
    '#/build/include/log4cplus/configurator.h',
    '#/build/include/log4cplus/config/win32.h',
    '#/build/include/log4cplus/fileappender.h',
    '#/build/include/log4cplus/fstreams.h',
    '#/build/include/log4cplus/helpers/lockfile.h',
    '#/build/include/log4cplus/helpers/pointer.h',
    '#/build/include/log4cplus/helpers/property.h',
    '#/build/include/log4cplus/helpers/snprintf.h',
    '#/build/include/log4cplus/helpers/socketbuffer.h',
    '#/build/include/log4cplus/helpers/socket.h',
    '#/build/include/log4cplus/helpers/thread-config.h',
    '#/build/include/log4cplus/helpers/timehelper.h',
    '#/build/include/log4cplus/layout.h',
    '#/build/include/log4cplus/logger.h',
    '#/build/include/log4cplus/loggingmacros.h',
    '#/build/include/log4cplus/loglevel.h',
    '#/build/include/log4cplus/spi/appenderattachable.h',
    '#/build/include/log4cplus/spi/filter.h',
    '#/build/include/log4cplus/spi/loggerfactory.h',
    '#/build/include/log4cplus/streams.h',
    '#/build/include/log4cplus/syslogappender.h',
    '#/build/include/log4cplus/tchar.h',
    '#/build/include/log4cplus/thread/syncprims.h',
    '#/build/include/log4cplus/tracelogger.h',
    '#/build/include/log4cplus/tstring.h',
]

products = libs + shlibs + headers

log4cplus_cfg = env.Command(products, str(Dir(vpath)), cmd)
env.SideEffect('config.status', log4cplus_cfg)

env.Alias('install', env.Install(env['INSTALL_LIB'], shlibs))

env.Alias('install',
          env.Symlink(env['INSTALL_LIB'] + '/liblog4cplus-1.1.so' + '.7',
                      env['INSTALL_LIB'] + '/liblog4cplus-1.1.so' + version))
